<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    * {
        padding: 0;
        margin: 0;
        list-style: none;
        box-sizing: border-box;
    }

    .box {
        width: 150px;
        margin: 0 auto;
        border: 1px solid #000;
        text-align: center;
    }

    ul {}

    li {
        line-height: 40px;
    }

    .li1 {
        border-bottom: 1px solid #000;
    }
</style>

<body>
    <div class="box">
        <ul>
            <li class="li1">
                <input type="checkbox">
                <span><b>全选</b><a href="#">反选</a></span>
            </li>
            <li>
                <input type="checkbox">
                <span>选项（一）</span>
            </li>
            <li>
                <input type="checkbox">
                <span>选项（二）</span>
            </li>
            <li>
                <input type="checkbox">
                <span>选项（三）</span>
            </li>
            <li>
                <input type="checkbox">
                <span>选项（四）</span>
            </li>
            <li>
                <input type="checkbox">
                <span>选项（五）</span>
            </li>
            <li>
                <input type="checkbox">
                <span>选项（六）</span>
            </li>
            <li>
                <input type="checkbox">
                <span>选项（七）</span>
            </li>
            <li>
                <input type="checkbox">
                <span>选项（八）</span>
            </li>
            <li>
                <input type="checkbox">
                <span>选项（九）</span>
            </li>
            <li>
                <input type="checkbox">
                <span>选项（十）</span>
            </li>
        </ul>
    </div>
</body>

</html>
<script>
    var Input = document.querySelectorAll('input')
    var b = document.querySelector('b')
    for (var i = 0; i < Input.length; i++) {
        // Input[i].index = i
        Input[0].onclick = function () {
            for (var j = 0; j < Input.length; j++) {
                if (this.checked == true) {
                    Input[j].checked = this.checked
                    b.innerHTML = '全不选'
                } else {
                    Input[j].checked = this.checked
                    b.innerHTML = '全选'
                }
            }
        }
        Input[i].onclick = function () {

            // console.log(1);
        }
    }
</script>